//
//  JDPrivateMessageTableViewCell.swift
//  DragonWallet
//
//  Created by volantPig on 2024/6/2.
//

import UIKit

class JDPrivateMessageTableViewCell: UITableViewCell {

    var containerView: UIView?
    
    var messageNumber: UILabel?
    var callBackMessageButton: UIButton?
    var callPhoneButton: UIButton?
    var messageContentLabel: UILabel?
    var separateLine: UIView?
    var releaseTime: UILabel?
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.backgroundColor = .commonColor()
        self.setupUIElements()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupUIElements() {
        
        self.containerView = UIView()
        self.contentView.addSubview(self.containerView!)
        self.containerView?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(12)
            make.right.equalTo(self.contentView).offset(-12)
            make.top.equalTo(self.contentView)
            make.bottom.equalTo(self.contentView).offset(-10)
        })
        self.containerView?.layer.cornerRadius = 8
        self.containerView?.backgroundColor = .white
        
        
        self.messageNumber = UILabel()
        self.containerView?.addSubview(self.messageNumber!)
        self.messageNumber?.snp.makeConstraints({ make in
            make.left.equalTo(self.containerView!).offset(12)
            make.top.equalTo(self.containerView!).offset(15)
        })
        self.messageNumber?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .medium), textColor: color("#333333"))
        self.messageNumber?.text = "私聊编号:9383473793"
        
        self.callPhoneButton = UIButton(type: .custom)
        self.containerView?.addSubview(self.callPhoneButton!)
        self.callPhoneButton?.snp.makeConstraints({ make in
            make.right.equalTo(self.containerView!).offset(-12)
            make.centerY.equalTo(self.messageNumber!)
            make.size.equalTo(CGSizeMake(21, 21))
        })
        self.callPhoneButton?.setImage(UIImage(named: "call_image")?.withRenderingMode(.alwaysOriginal), for: .normal)

        self.callBackMessageButton = UIButton(type: .custom)
        self.containerView?.addSubview(self.callBackMessageButton!)
        self.callBackMessageButton?.snp.makeConstraints({ make in
            make.right.equalTo(self.callPhoneButton!.snp.left).offset(-14)
            make.centerY.equalTo(self.callPhoneButton!)
            make.size.equalTo(CGSizeMake(21, 20))
        })
        self.callBackMessageButton?.backgroundColor = color("#333333")
        
//        var messageNumber: UILabel?
//        var callBackMessageButton: UIButton?
//        var callPhoneButton: UIButton?
        self.messageContentLabel = UILabel()
        self.containerView?.addSubview(self.messageContentLabel!)
        self.messageContentLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.containerView!).offset(12)
            make.right.equalTo(self.containerView!).offset(-12)
            make.top.equalTo(self.messageNumber!.snp.bottom).offset(26)
        })
        self.messageContentLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 16, weight: .regular), textColor: color("#333333"), numberOfLines: 0)
        self.messageContentLabel?.text = "请问，幼儿学前教育包含什么样的课程，早中晚作息时间是怎样的，是否包含晚饭。"
//        var messageContentLabel: UILabel?
        
        self.separateLine = UIView()
        self.containerView?.addSubview(self.separateLine!)
        self.separateLine?.snp.makeConstraints({ make in
            make.left.equalTo(self.containerView!).offset(12)
            make.right.equalTo(self.containerView!).offset(-12)
            make.top.equalTo(self.messageContentLabel!.snp.bottom).offset(9)
            make.height.equalTo(1)
            make.bottom.equalTo(self.containerView!).offset(-47)
        })
        self.separateLine?.backgroundColor = color("#F5F6F8")
//        var separateLine: UIView?
//        var releaseTime: UILabel?
        
        self.releaseTime = UILabel()
        self.containerView?.addSubview(self.releaseTime!)
        self.releaseTime?.snp.makeConstraints({ make in
            make.left.equalTo(self.containerView!).offset(12)
            make.top.equalTo(self.separateLine!.snp.bottom)
            make.bottom.equalTo(self.containerView!)
        })
        self.releaseTime?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 13, weight: .regular), textColor: color("#333333"))
        self.releaseTime?.text = "发布时间:3天前"
        
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
